package Leo.serviceClient.controller;

import Leo.serviceClient.entity.Member;
import Leo.serviceClient.entity.Result;
import Leo.serviceClient.entity.User;
import Leo.serviceClient.feign.ProviderClient;
import Leo.serviceClient.feign.XmlClient;
import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.netflix.ribbon.proxy.annotation.Hystrix;
import feign.FeignException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
@RequestMapping("/feign")
public class FeignController {

    @Autowired
    ProviderClient providerClient;

    @Autowired
    XmlClient xmlClient;

    @RequestMapping("/test")
    String test() {
        return providerClient.test();
    }

    @RequestMapping("/getUser")
    User getUser(@RequestParam("userId") String userId) {
        User user = providerClient.getUser(userId);
        return user;
    }

    @RequestMapping("/getXmlUser")
    String getXmlUser() {
        Member user = new Member();
        user.setUserId("3434");
        user.setUserName("小果果");
        String result = xmlClient.getXmlUser(user);
//        System.out.println(result);
        return result;
    }

    @RequestMapping("/stringUser")
    String stringUser() {
        User user = new User();
        user.setUserId("3434");
        user.setUserName("小果果");
        String result = xmlClient.stringUser("<root><name>guoguo</name></root>");
//        System.out.println(result);
        return result;
    }


}
